<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/1/3 0003
 * Time: 15:24
 */
$http = new swoole_http_server('192.168.3.221', 8811);

//设置静态文件直接访问
$http->set([
    'worker_num' => 4,
    'enable_static_handler' => true,
    'document_root' => '/data/wwwroot/www/swoole-demo/mooc/data/',
]);

$http->on('request', function($request, $response){
    print_r($request->get);
    $data = [
        'date:' => date('Y-m-d H:i:s'),
        'get:' => $request->get,
        'post:' => $request->post,
        'header:' => $request->header
    ];
    swoole_async_writefile(__DIR__.'/http.log', json_encode($data).PHP_EOL, function($filename){},FILE_APPEND);
    $response->cookie('singwa', 'xssss', time()+1800);
    $response->end("<h1>HTTPserver</h1>"."\r\n".'sss'.json_encode($request->get));
});

$http->start();











